<div class="comm-top">
	<div class="title-left">
		数据列表
	</div>
	<div class="title-right" style="top:12px;">
		<input value="同步分组" class="btn btn-success search_btn" type="button" id="syncBtn" onclick="syncGroup(this)" />
		<input value="添加分组" class="btn btn-success search_btn" type="button" onclick="location.href='group.php?a=add'" />
	</div>
</div>
<div class="list-table">
	<div class="wrapper">
		<table class="stable">
			<thead>
				<tr>
					<th>分组名</th>
					<th>人数</th>
					<th>用户列表</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
                <form id="memberForm">
                <{foreach from=$list item=v}>
					<tr>
						<td><{$v.group_name}></td>
						<td><{$v.count_num|default:0}></td>
						<td><a href="list.php?group_id=<{if $v.group_id==0}>-1<{else}><{$v.group_id}><{/if}>" style="font-size:14px;color:#009997;">查看</a></td>
						<td><div class="btn-operate">
                            <{if $v.group_id > 2}>
                            <a href="group.php?a=add&id=<{$v.id}>" title="修改"><i class="glyphicon glyphicon-edit"></i></a>
                            <a href="javascript:void(0);" onclick="delRow('<{$v.id}>','<{$v.group_id}>',this)" title="删除" id="delBtn<{$v.id}>"><i class="glyphicon glyphicon-trash"></i></a>
                            <{/if}>
                        </div></td>
					</tr>
                <{/foreach}>
                </form>
			</tbody>
		</table>
	</div>
</div>
<{if $page}><div class="page-list"><{$page}></div><{/if}>
<script type="text/javascript">
function delRow(id,group_id,obj){
    if(confirm('确定要删除吗？')){
        var layerLoad=layer.load(1,{shade:[0.1,'#666']});
        $.post('group.php',{a:'del',id:id,group_id:group_id},function(res){
            layer.close(layerLoad);
            res=$.trim(res);
            if(res=='suc'){
                note_info('删除成功',obj);
                setTimeout('location.reload()',1200);
            }else{
                note_info('删除失败',obj,'warn');
            }
        });
    }
}
//同步分组
function syncGroup(obj){
    if(confirm('同步分组会将微信已有的分组同步到本地，确定要执行此操作吗？')){
        var layerLoad=layer.load(1,{shade:[0.1,'#666']});
        $.post('group.php',{a:'sync'},function(res){
            layer.close(layerLoad);
            res=$.trim(res);
            if(res=='suc'){
                note_info('同步成功',obj);
                setTimeout('location.reload()',1200);
            }else{
                note_info('同步失败',obj,'warn');
            }
        });
    }
}
</script>